package thread;

public class SyncDome2 {
    public static void main(String[] args) {
        /*
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                Boo.dosome();
            }
        });
         */
        /*
        Thread t2 = new Thread(()-> {Boo.dosome();});
         */


        Thread t1 = new Thread(Boo::dosome){
            public void run(){
                Boo.dosome();
            }
        };

        Thread t2 = new Thread(Boo::dosome){
            public void run(){
                Boo.dosome();
            }
        };
        t1.start();
        t2.start();


    }

}
class Boo{
    //public synchronized static void dosome(){
    public static void dosome(){
        synchronized (Boo.class){//Boo.class是当前类对象
            try {
                Thread t = Thread.currentThread();
                System.out.println("正在执行");
                Thread.sleep(3000);
                System.out.println("执行完毕");
            } catch (InterruptedException e) {
            }
        }
    }
}